<?php

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AuthController as BaseAuthController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuthController extends BaseAuthController
{
    public function postLogin(Request $request)
    {

        $response = parent::postLogin($request);

        $user = Auth::guard('admin')->user();
        if($user && $user->isRole('agent')){
            //代理登录
            $response->setTargetUrl(env('APP_URL').'/admin/agent/index');
        }
        return $response;
    }
}
